package com.hifar.test.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hifar.test.test.mapper.HfEnvTestSensorMapper;
import com.hifar.test.test.pojo.HfEnvTestSensor;
import com.hifar.test.test.service.IHfEnvTestSensorService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhuWeiWei
 * @description 试验传感器
 * @date 2025/1/14 18:16
 */
@Service
public class HfEnvTestSensorServiceImpl extends ServiceImpl<HfEnvTestSensorMapper, HfEnvTestSensor> implements IHfEnvTestSensorService {
    @Override
    public void removeByTestId(String testId) {
        QueryWrapper<HfEnvTestSensor> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(HfEnvTestSensor::getTestId, testId);
        this.remove(queryWrapper);
    }

    @Override
    public List<HfEnvTestSensor> listByTestId(String testId) {
        QueryWrapper<HfEnvTestSensor> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(HfEnvTestSensor::getTestId, testId)
                .orderByAsc(HfEnvTestSensor::getRowSort);
        return this.list(queryWrapper);
    }

    @Override
    public List<HfEnvTestSensor> listByTestIds(List<String> testIdList) {
        if (testIdList.isEmpty()) {
            return new ArrayList<>();
        }
        QueryWrapper<HfEnvTestSensor> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .in(HfEnvTestSensor::getTestId, testIdList)
                .orderByAsc(HfEnvTestSensor::getRowSort);
        return this.list(queryWrapper);
    }
}
